package sjtu.pirate.util;

import sjtu.pirate.format.Form;
/**
 * @author wilbur.ma@qq.com
 * @date 2011.05.31
 */
public class FormHelper {
	public static String buildFormLink(Form f) {
		return buildFormLink(f.getURI().getHost(), buildFormPath(f));
	}
	
	public static String buildFormLink(String host, String path) {
		return host + "/" + path.replace('/', '_').replace(':', '+') + ".html";
	}

	public static String buildFormPath(Form f) {
		if (f.getName() == null)
			f.setName("anonymous");
		return f.getURI().getPath() + ":" + f.getName();
	}
	
	public static String buildHostID(String host) {
		return host.replace('.', '_');
	}
}
